package com.hualan.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
public class ResultEntity implements Serializable {
    private Integer code;//状态码
    private String msg;//描述信息
    private Object data;//返回的数据
    public static ResultEntity ok(){
        ResultEntity result = new ResultEntity(200,"操作成功",null);
        return  result;
    }
    public static ResultEntity ok(Object data){
        ResultEntity result = new ResultEntity(200,"操作成功",data);
        return  result;
    }
    public static ResultEntity ok(String msg,Object data){
        ResultEntity result = new ResultEntity(200,msg,data);
        return  result;
    }

    public static ResultEntity error(){
        ResultEntity result = new ResultEntity(500,"操作失败",null);
        return  result;
    }
    public static ResultEntity error(Integer code){
        ResultEntity result = new ResultEntity(code,"操作失败",null);
        return  result;
    }
    public static ResultEntity error(Integer code,String msg){
        ResultEntity result = new ResultEntity(code,msg,null);
        return  result;
    }


    public ResultEntity(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
